var express = require('express');
var router = express.Router();

var model = require('../model/user.js');

router.use(function(req,res,next) {
	next()
});

router.post('/login',(req,res,next)=> {
	var info = req.body;
	if (info['username'] == undefined || info['password'] == undefined) {
		res.send({status:400,msg:"用户名/密码不能为空"});
		return;
	}

	model.login(info).then(v =>{
		res.send(v);
	});
});

router.post('/reg',(req,res,next)=> {
	var info = req.body;
	model.reg(info).then(v=>{
		res.send(v);
	});
});

router.get('/queryprofile',(req,res,next)=> {
	let pid = req.query.pid;
	model.queryprofile(pid).then(v=>{
		res.send(v);
	});
});

router.get('/list',(req,res,next)=> {
	model.list().then(v=>{
		res.send(v);
	});
});

router.post('',(req,res,next)=> {
	
});

router.post('',(req,res,next)=> {
	
});

router.post('',(req,res,next)=> {
	
});

router.post('',(req,res,next)=> {

});


module.exports = router;